/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package colloque.servlets;

import colloque.forms.ColloqueForm;
import colloque.helpers.MotCleHelper;
import colloque.helpers.SecurityHelper;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author James
 */
public class CreerColloque extends HttpServlet {

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /* Affichage de la page de connexion */
        SecurityHelper security = new SecurityHelper(request.getSession());
        if (security.isAuthenticated() == false) {
            response.sendRedirect("Connexion");
        } else {
            try {
                MotCleHelper mchelper = new MotCleHelper();
                request.setAttribute("motscles", mchelper.getallmc());
            } catch (Exception e) {
                e.printStackTrace();
            }
            this.getServletContext().getRequestDispatcher("/jsp/CreerColloque.jsp").forward(request, response);
        }
    }

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ColloqueForm colloque_form = new ColloqueForm();
        colloque_form.createColloque(request);
        this.getServletContext().getRequestDispatcher("/jsp/CreerColloque.jsp").forward(request, response);
    }
}
